package chapter6;
import java.util.Scanner;
/****************************************************************
 * Author：icynlau
 * Description: 编写方法计算级数
运行结果
i                  m(i)
===========
1                  0.5000
2                  1.1667
3                  1.9167
4                  2.7167
5                  3.5500
6                  4.4071
7                  5.2821
8                  6.1710
9                  7.0710
10                 7.9801
11                 8.8968
12                 9.8199
13                10.7484
14                11.6818
15                12.6193
16                13.5604
17                14.5049
18                15.4523
19                16.4023
20                17.3546

 * Date:2021/4/4
 * ***************************************************************
 */
public class exc6_13 {
	
	public static double compute(int n) {
		
		double sum=0;
		
		for(int i=1;i<=n;i++) {
			
			sum+=i*1.0/(i+1);
			
		}
		
		return sum;
		
	}

	
	public static void main(String[] args) {
		
		System.out.print("i                  m(i)\n");
		System.out.print("===========\n");
		
		
		for(int i=0;i<20;i++) {
			
			System.out.printf("%-2d               %8.4f\n", i+1,compute(i+1));
			
		}
		
	}
	
}
